package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.omg.Messaging.SyncScopeHelper;

import business.RegisterBusiness;

public class RegisterServlet extends HttpServlet{
	public void init() throws ServletException{	}
	public void doPost (HttpServletRequest request, HttpServletResponse response)
			throws ServletException,IOException { 
			doGet (request, response);
		}
	
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String username = request.getParameter("username");
		System.out.println(username);
		String password = request.getParameter ("password"); 
		String state = request.getParameter ("state"); 
		int stateint = Integer.parseInt(state);
		RegisterBusiness rb = new RegisterBusiness();
		boolean flag = rb.register(username,password,stateint);
		
		if (flag)
			response.sendRedirect (request.getContextPath ()+"/login.jsp");
		
		else
					response. sendRedirect (request.getContextPath () +"/error.jsp");
			//System.out.println(str);
		}

}
